#!/bin/bash


src_files=(
    ${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/system_stm32f4xx.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/stm32f4xx_it.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/startup_stm32f405xx.s \

	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/lt_drivers/drv_gpio.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/lt_drivers/drv_serial.c \
	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/lt_drivers/drv_flashio.c \

	${LITOS_PROJECT_DIR}/bsp/${LITOS_CHIP}/board.c \
)

set -e

for cfile in ${src_files[*]}
do
	if [ "${cfile##*.}"x = "c"x ];then
		filename=${cfile##*/}
		echo "CC ${filename}.c -o ${filename}.o"
		${CC} ${CHIP_INCLUDES} ${APP_INCLUDES} ${CFLAGS}  -c ${cfile} -o ${LITOS_PROJECT_DIR}/build/${filename}.o 
	fi

	if [ "${cfile##*.}"x = "s"x ];then
		filename=${cfile##*/}
		echo "CC ${filename}.s -o ${filename}.o"
		${CC} ${CHIP_INCLUDES} ${APP_INCLUDES} ${ASFLAGS} -c ${cfile} -o ${LITOS_PROJECT_DIR}/build/${filename}.o 
	fi
done
